import { defineStore } from 'pinia'
import piniaPluginPersist from "pinia-plugin-persist"

interface IUser {
	nick: string
	headerimg: string
	username:string
	password:string	
}

export const userStore = defineStore('user', {
	state: () => {
		return {
			user: {nick:'',headerimg:''},			
		}
	},
	actions: {
		saveUser(user: IUser) {
			this.user = user
		},
				
	},
    getters:{
        userInfo:(state)=>state.user,	
    },
	persist:{
		enabled:true,
		strategies:[
			{
				key:'userKey',
				storage:localStorage,
				paths:[
					'user'
				]
			}
		]
	}
})